package cn.edu.qlnu.xky.test.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MsgExchage {

	public static String chGender(String gender) {
		if(gender == null) {
			return "错误性别";
		}else {
			if(gender.equals("0"))
				return "男";
			else
				return "女";
		}
	}
	
	public static String chDate(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(date);
	}
	
	public static Date stringToDate(String date) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		try {
			return sdf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static String exeChangeSchool(String code) {
		String ret="";
		switch(code) {
		case "qlnu":
			ret = "齐鲁师范学院";break;
		case "sdu":
			ret = "山东大学";break;
		case "sdnu":
			ret = "山东师范大学";break;
		
		}
		return ret;
	}
	
	private static String exeChangeHobby(String code) {
		String ret="";
		switch(code) {
		case "0":
			ret = "爬山";break;
		case "1":
			ret = "打篮球";break;
		case "2":
			ret = "听音乐";break;
		case "3":
			ret = "跳舞";break;
		case "4":
			ret = "玩游戏";break;
		}
		return ret;
	}
	
	
	public static String chHobbies(String[] hobbies) {
		if(hobbies == null)
			return "";
		else {
			String ret="";
			for(String hob : hobbies) {
				ret +=exeChangeHobby(hob)+" ";
			}
			return ret;
		}
	}
	
	public static String keyHobbies(String[] hobbies) {
		if(hobbies == null)
			return "";
		else {
			String ret="";
			for(String hob : hobbies) {
				ret +=hob+" ";
			}
			return ret;
		}
	}
}
